package com.hmdp.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zcf
 */
@Configuration
public class RabbitMQTopicConfig {
    //设置队列

    //设置交换机

    //设置Routing key

    //创建三个bean对象

    //1.new 队列

    //2.new 交换机

    //3.绑定关系
    //队列
    public static final String QUEUE = "seckillQueue";
    //交换机
    public static final String EXCHANGE = "seckillExchange";
    //路由
    public static final String ROUTINGKEY = "seckill.#";
    @Bean
    public Queue queue(){
        return new Queue(QUEUE);
    }
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(EXCHANGE);
    }
    @Bean
    public Binding binding(){
        return BindingBuilder.bind(queue()).to(topicExchange()).with(ROUTINGKEY);
    }



}
